package com.ly.heart.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ly.common.utils.DateUtils;
import com.ly.common.utils.StringUtils;
import com.ly.heart.mapper.SupplierContactsMapper;
import com.ly.heart.service.ISupplierContactsService;
import org.springframework.stereotype.Service;
import com.ly.heart.domain.SupplierContactsEntity;

import javax.annotation.Resource;

/**
 * 供应商联系人Service业务层处理
 *
 * @author cxl
 * @date 2024-06-16
 */
@Service
public class SupplierContactsServiceImpl extends ServiceImpl<SupplierContactsMapper, SupplierContactsEntity> implements ISupplierContactsService {

    @Resource
    private SupplierContactsMapper supplierContactsMapper;

    /**
     * 查询供应商联系人
     *
     * @param id 供应商联系人ID
     * @return 供应商联系人
     */
    @Override
    public SupplierContactsEntity selectSupplierContactsEntityById ( String id ) {
        return supplierContactsMapper.selectSupplierContactsEntityById ( id );
    }

    /**
     * 查询供应商联系人列表
     *
     * @param supplierContactsEntity 供应商联系人
     * @return 供应商联系人
     */
    @Override
    public IPage selectSupplierContactsEntityList ( SupplierContactsEntity supplierContactsEntity ) {
        LambdaQueryWrapper<SupplierContactsEntity> lambdaQueryWrapper = new LambdaQueryWrapper ();
        if ( StringUtils.isNotBlank ( supplierContactsEntity.getSupplierId () ) ) {
            lambdaQueryWrapper.eq ( SupplierContactsEntity :: getSupplierId, supplierContactsEntity.getSupplierId () );
        }
        IPage page = this.page ( new Page<> ( supplierContactsEntity.getPage (), supplierContactsEntity.getLimit () ), lambdaQueryWrapper );
        return page;
    }

    /**
     * 新增供应商联系人
     *
     * @param supplierContactsEntity 供应商联系人
     * @return 结果
     */
    @Override
    public int insertSupplierContactsEntity ( SupplierContactsEntity supplierContactsEntity ) {
        supplierContactsEntity.setCreateTime ( DateUtils.getNowDate () );
        return supplierContactsMapper.insertSupplierContactsEntity ( supplierContactsEntity );
    }

    /**
     * 修改供应商联系人
     *
     * @param supplierContactsEntity 供应商联系人
     * @return 结果
     */
    @Override
    public int updateSupplierContactsEntity ( SupplierContactsEntity supplierContactsEntity ) {
        return supplierContactsMapper.updateSupplierContactsEntity ( supplierContactsEntity );
    }

    /**
     * 批量删除供应商联系人
     *
     * @param ids 需要删除的供应商联系人ID
     * @return 结果
     */
    @Override
    public int deleteSupplierContactsEntityByIds ( String[] ids ) {
        return supplierContactsMapper.deleteSupplierContactsEntityByIds ( ids );
    }

    /**
     * 删除供应商联系人信息
     *
     * @param id 供应商联系人ID
     * @return 结果
     */
    @Override
    public int deleteSupplierContactsEntityById ( String id ) {
        return supplierContactsMapper.deleteSupplierContactsEntityById ( id );
    }
}
